package com.heima.behavior.controller;

import com.heima.behavior.service.ApLikesBehaviorService;
import com.heima.behavior.service.ApReadBehaviorService;
import com.heima.behavior.service.ApUnlikeBehaviorService;
import com.heima.model.behavior.dtos.LikesBehaviorDTO;
import com.heima.model.behavior.dtos.ReadBehaviorDTO;
import com.heima.model.behavior.dtos.UnLikesBehaviorDTO;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 点赞控制层
 */
@RestController
@RequestMapping("/api/v1")
public class ApLikesBehaviorController {
    @Autowired
    private ApLikesBehaviorService apLikesBehaviorService;

    @Autowired
    private ApReadBehaviorService apReadBehaviorService;

    @Autowired
    private ApUnlikeBehaviorService apUnlikeBehavior;

    @PostMapping("/likes_behavior")
    public ResponseResult like(@RequestBody LikesBehaviorDTO dto) {
        return apLikesBehaviorService.like(dto);
    }

    @PostMapping("/read_behavior")
    public ResponseResult read(@RequestBody ReadBehaviorDTO dto) {
        return apReadBehaviorService.readBehavior(dto);
    }

    @PostMapping("/un_likes_behavior")
    public ResponseResult unLike(@RequestBody UnLikesBehaviorDTO unLikesBehaviorDTO) {
        return apUnlikeBehavior.unlikeBehavior(unLikesBehaviorDTO);
    }
}
